package com.da.nio;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.nio.channels.FileChannel;

public class NIOFileChannel04 {
    public static void main(String[] args) throws Exception {
        //创建相关流
        FileInputStream inputStream = new FileInputStream("d:\\a.jpg");
        FileOutputStream outputStream = new FileOutputStream("d:\\b.jpg");
        //获取各个流对应的filechannel
        FileChannel in = inputStream.getChannel();
        FileChannel out = outputStream.getChannel();
        //使用transferForm完成拷贝
        out.transferFrom(in, 0, in.size());
        //关闭相关通道和流
        in.close();
        out.close();
        inputStream.close();
        outputStream.close();
    }
}
